#!/usr/bin/gmake -f
#
# Makefile
#
# Copyright (c) 2012 Sonia Keys
#
# See external file LICENSE, distributed with this software.

.PHONY: all
all: digest2 digest2.model digest2.obscodes

# digest2 executable
d2src = digest2.c d2model.c d2math.c d2mpc.c

digest2: $(d2src) digest2.h d2model.h
	gcc -o digest2 -std=c99 -Wall -pthread $(d2src) -lm -static

# data file needed by digest2
digest2.model: muk s3m.dat astorb.dat
	./muk

# muk executable
muksrc = muk.c d2model.c

muk: $(muksrc) d2model.h
	gcc -o muk -std=c99 -Wall -lm $(muksrc)

# astorb.dat
astorb.dat:
	wget --ftp-user=anonymous "ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz"
	gunzip "astorb.dat.gz"

# mpc.obscodes
digest2.obscodes:
	wget --ftp-user=anonymous "http://www.minorplanetcenter.net/iau/lists/ObsCodes.html" -O - | sed '1d;$$d' >digest2.obscodes
